#include "CameraEvaluator.h"
#ifdef __ANDROID__
#include "AndroidVideoCapture.h"
#include "AndroidVideoCaptureFactory.h"
#endif

namespace simple_renderer{

CameraEvaluator::CameraEvaluator() : _frame_renderer(nullptr) {

#ifdef __ANDROID__
    _video_capture.reset(new AndroidVideoCapture);
    _video_capture_factory.reset(new AndroidVideoCaptureFactory);
#endif
}

CameraEvaluator::~CameraEvaluator(){
    _video_capture = nullptr;
}

int CameraEvaluator::AllocCapture(){

    _video_capture = std::move(_video_capture_factory->CreateVideoCapture());
    return _video_capture->AllocCapture();
}
int CameraEvaluator::DeallocCapture(){

    return _video_capture->DeallocCapture();
}

int CameraEvaluator::StartCapture(){

    return _video_capture->StartCapture();
}
int CameraEvaluator::StopCapture(){

    return _video_capture->StopCapture();
}

void CameraEvaluator::MoveIntoRenderer(std::unique_ptr<FrameRenderer> &frame_renderer){
    _frame_renderer = std::move(frame_renderer);
}

std::unique_ptr<FrameRenderer> CameraEvaluator::MoveOutRenderer(){
    auto ret = std::move(_frame_renderer);
    _frame_renderer = nullptr;
    return ret;
}

}